import { pageQueryVolunteer, logicDeleteVolunteerById, logicBatchDeleteVolunteerByIds } from '@/api/admin/common';
import { message, messageType } from '@/utils/message'
const state = {
    VolunteerRespData: [],
    total: 0,
};
const mutations = {

    // 分页查询用户
    pageQueryVolunteerListMutations(state, param) {
        console.log('userMutations-->', param.data);
        state.VolunteerRespData = param.data;
        state.total = param.total;
    },

    /* queryRoleMutations(state, param) {
        state.role = param.data;
    } */
};
const actions = {
    // 分页查询用户
    async pageQueryVolunteerListActions(context, page) {
        await pageQueryVolunteer(page).then(resp => {
            if (!resp) return;
            context.commit('pageQueryVolunteerListMutations', resp.data)
        }, error => {
            console.log(error);
        })
    },

    // 逻辑删除自愿者信息
    async logicDeleteVolunteerByIdActions(context, id) {
        await logicDeleteVolunteerById(id).then(resp => {
            if (!resp) return;
            message(messageType().success, '操作成功');
        }, error => {
            console.log(error);
        })
    },
    // 批量逻辑删除自愿者信息
    async logicBatchDeleteVolunteerByIdsActions(context, ids) {
        await logicBatchDeleteVolunteerByIds(ids).then(resp => {
            if (!resp) return;
            message(messageType().success, '操作成功');
        }, error => {
            console.log(error);
        })
    },

    /* // 查询角色
    async queryRoleActions(context) {
        queryRole().then(resp => {
            console.log(resp);
            context.commit('queryRoleMutations', resp.data)
        }, error => {
            console.log(error);
        })
    } */
};

export default {
    namespaced: true,
    state,
    mutations,
    actions,
}